<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .aa{
            width: 200px;
            height: 200px;
        }
    </style>
</head>

<body>
    <div class="box">
        <label for="">
            <img src="../../../web/img/01.jpg" alt="" id="eye" class="aa">
        </label>
        <input type="password" name="" id="pwd">
    </div>
    <script>
        //     需求 ； 点击图片 ； 图片 src 变化， 表单类型变化
        let img = document.querySelector('img')
        let input = document.querySelector('input')
        let flag = true;
        img.onclick = function () {
            
            if (flag) {               
                img.src = "../../../web/img/02.jpg"
                input.type = 'text';
            } else {
                img.src = "../../../web/img/01.jpg"
                input.type = 'password';
            }
            flag=!flag;
        }
    </script>
</body>

</html>